import { NextResponse } from "next/server";
import { PostService } from "@/utils/prisma";


export async function POST(request: Request) {
    const { action, params } = await request.json();
    try {
        switch (action) {
            case "init": {
                const allPost = await PostService.getAllPosts();
                return NextResponse.json({ data: allPost, status: 200 });
            }
            case "read": {

                try {
                    // PostService.createPost("Pigs is Pigs", out, "all")
                    return NextResponse.json({
                        data: [],
                        status: 200,
                    })
                } catch (e) {
                    // console.log(e, 894);
                    return NextResponse.json({
                        status: 500,
                        error: "Failed to process request",
                    });
                }

            }

            default:
                return NextResponse.json({ status: 400, error: "Invalid action" });
        }
    } catch (error) {
        console.error(error);
        return NextResponse.json({
            status: 500,
            error: "Failed to process request",
        });
    }
}
